import rtconfig
Import('RTT_ROOT')
from building import *

# get current directory
cwd = GetCurrentDir()

# The set of source files associated with this SConscript file.
src = Split("""
CMSIS/Nuvoton/M051Series/Source/system_M051Series.c
""")

src += Glob('StdDriver/src/*.c')

#add for startup script 
if rtconfig.CROSS_TOOL == 'iar':
     src = src + ['CMSIS/Nuvoton/M051Series/Source/IAR/startup_M051Series.s']
elif rtconfig.CROSS_TOOL == 'keil':
     src = src + ['CMSIS/Nuvoton/M051Series/Source/ARM/startup_M051Series.s']
elif rtconfig.CROSS_TOOL == 'gcc':
     src = src + ['CMSIS/Nuvoton/M051Series/Source/GCC/startup_M051Series.s']

path = [cwd + '/StdDriver/inc', 
    cwd + '/CMSIS/Nuvoton/M051Series/Include',
    cwd + '/CMSIS/Include']

#CPPDEFINES = ['USE_STDPERIPH_DRIVER', rtconfig.STM32_TYPE]
CPPDEFINES = ['INIT_SYSCLK_AT_BOOTING']
group = DefineGroup('M05X_StdPeriph', src, depend = [''], CPPPATH = path, CPPDEFINES = CPPDEFINES)

Return('group')
